package com.sg.java.util;

import com.sg.java.PropertiesUtil;
import com.sg.java.ResourcePath;
import redis.clients.jedis.Jedis;

import java.util.Properties;

public class RedisUtils {

    private static volatile Jedis jedis = null;

    public static Jedis getInstance() {
        if (jedis == null) {
            synchronized (RedisUtils.class) {
                if (jedis == null) {
                    Properties prop = PropertiesUtil.createPropertiesFromResource(ResourcePath.redis_properties);
                    String host = prop.getProperty("host", "25.64.41.53");
                    int port = Integer.parseInt(prop.getProperty("port", "6379"));
                    String password = prop.getProperty("password", "Huawei@169");
                    jedis = new Jedis(host, port);
                    jedis.auth(password);
                }
            }
        }
        return jedis;
    }

}
